<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>hsm-statechart: hsm/hsm_context.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="hsm-statechart.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">hsm-statechart
   &#160;<span id="projectnumber">0.5</span>
   </div>
   <div id="projectbrief">An easy to use hierarchical state machine for C and C++</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('hsm__context_8h.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">hsm_context.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Support for optional per-state instance data.  
<a href="#details">More...</a></p>

<p><a href="hsm__context_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:structhsm__context__rec"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="hsm__context_8h.html#structhsm__context__rec">hsm_context_rec</a></td></tr>
<tr class="memdesc:structhsm__context__rec"><td class="mdescLeft">&#160;</td><td class="mdescRight">A per state instance context object.  <a href="hsm__context_8h.html#structhsm__context__rec">More...</a><br/></td></tr>
<tr class="memitem:structhsm__context__stack__rec"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="hsm__context_8h.html#structhsm__context__stack__rec">hsm_context_stack_rec</a></td></tr>
<tr class="memdesc:structhsm__context__stack__rec"><td class="mdescLeft">&#160;</td><td class="mdescRight">Per state machine instance manager of context data.  <a href="hsm__context_8h.html#structhsm__context__stack__rec">More...</a><br/></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ad88f48148553f7cfe63cce03b3d16bab"><td class="memItemLeft" align="right" valign="top">typedef void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="hsm__context_8h.html#ad88f48148553f7cfe63cce03b3d16bab">hsm_callback_popped_context</a> )(<a class="el" href="hsm__context_8h.html#structhsm__context__rec">hsm_context_t</a> *)</td></tr>
<tr class="memdesc:ad88f48148553f7cfe63cce03b3d16bab"><td class="mdescLeft">&#160;</td><td class="mdescRight">Hear about your context object after just after its been popped.  <a href="#ad88f48148553f7cfe63cce03b3d16bab"></a><br/></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a37882939881b43db4f51a7cc24544f11"><td class="memItemLeft" align="right" valign="top"><a class="el" href="hsm__forwards_8h.html#aa0e37ff043d2dd5216cc762ca03046cb">hsm_context</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="hsm__context_8h.html#a37882939881b43db4f51a7cc24544f11">HsmContextAlloc</a> (size_t size)</td></tr>
<tr class="memdesc:a37882939881b43db4f51a7cc24544f11"><td class="mdescLeft">&#160;</td><td class="mdescRight">Helper to create a new context object.  <a href="#a37882939881b43db4f51a7cc24544f11"></a><br/></td></tr>
<tr class="memitem:ab3a13b1fa2faea3f79edb11b10217a1a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="hsm__context_8h.html#structhsm__context__stack__rec">hsm_context_stack</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="hsm__context_8h.html#ab3a13b1fa2faea3f79edb11b10217a1a">HsmContextStack</a> (<a class="el" href="hsm__context_8h.html#structhsm__context__stack__rec">hsm_context_stack_t</a> *stack, <a class="el" href="hsm__forwards_8h.html#aa0e37ff043d2dd5216cc762ca03046cb">hsm_context</a> init)</td></tr>
<tr class="memdesc:ab3a13b1fa2faea3f79edb11b10217a1a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Resets the hsm_context_stack structure.  <a href="#ab3a13b1fa2faea3f79edb11b10217a1a"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Support for optional per-state instance data. </p>

<p>Definition in file <a class="el" href="hsm__context_8h_source.html">hsm_context.h</a>.</p>
</div><hr/><h2>Data Structure Documentation</h2>
<a name="structhsm__context__rec" id="structhsm__context__rec"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct hsm_context_rec</td>
        </tr>
      </table>
</div><div class="memdoc">
<div class="textblock"><p>A per state instance context object. </p>
<p>You can "derive" from this structure by making the first member of your own structure</p>
<dl class="section note"><dt>Note:</dt><dd>lifetime must be &gt;= duration of its associated state(s). </dd></dl>

<p>Definition at line <a class="el" href="hsm__context_8h_source.html#l00040">40</a> of file <a class="el" href="hsm__context_8h_source.html">hsm_context.h</a>.</p>
</div><table class="fieldtable">
<tr><th colspan="3">Data Fields</th></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a8255e503c7879da580d5a697dba582a7"></a><a class="el" href="hsm__context_8h.html#structhsm__context__rec">hsm_context_t</a> *</td>
<td class="fieldname">
parent</td>
<td class="fielddoc">
</td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="ad0208ce8f889006d0c5f3d92c030dd2b"></a><a class="el" href="hsm__context_8h.html#ad88f48148553f7cfe63cce03b3d16bab">hsm_callback_popped_context</a></td>
<td class="fieldname">
popped</td>
<td class="fielddoc">
per context callback </td></tr>
</table>

</div>
</div>
<a name="structhsm__context__stack__rec" id="structhsm__context__stack__rec"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct hsm_context_stack_rec</td>
        </tr>
      </table>
</div><div class="memdoc">
<div class="textblock"><p>Per state machine instance manager of context data. </p>
<p>note: the most effienct implementation depends on the sparsity of the stack if it's very sparse: a list of (context,depth) tuples might be best if it's very full: an array of [context,...] with blank elements(*) might be best flagging is somewhere in between, though, all methods are probably fine for most people. </p>

<p>Definition at line <a class="el" href="hsm__context_8h_source.html#l00075">75</a> of file <a class="el" href="hsm__context_8h_source.html">hsm_context.h</a>.</p>
</div><table class="fieldtable">
<tr><th colspan="3">Data Fields</th></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a74b87d8a36ddc6006b1f4511c8b2b48f"></a><a class="el" href="hsm__forwards_8h.html#aa0e37ff043d2dd5216cc762ca03046cb">hsm_context</a></td>
<td class="fieldname">
context</td>
<td class="fielddoc">
most recently added unique context pointer </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a1e97dda6f0163b4a8b24d430ed603b93"></a><a class="el" href="hsm__types_8h.html#aaa094fe6ac1bf8728ffc38f2a7ef5703">hsm_uint16</a></td>
<td class="fieldname">
count</td>
<td class="fielddoc">
total number of pushes that have occured ( always &gt;= the depth of the statemachine's deepest state ) </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a1483325021805936ca81887f962c621d"></a><a class="el" href="hsm__types_8h.html#aaa094fe6ac1bf8728ffc38f2a7ef5703">hsm_uint16</a></td>
<td class="fieldname">
presence</td>
<td class="fielddoc">
bit flags for whether a push added unique data </td></tr>
</table>

</div>
</div>
<hr/><h2>Typedef Documentation</h2>
<a class="anchor" id="ad88f48148553f7cfe63cce03b3d16bab"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef void(* hsm_callback_popped_context)(<a class="el" href="hsm__context_8h.html#structhsm__context__rec">hsm_context_t</a> *)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Hear about your context object after just after its been popped. </p>
<p>Can be used to free memory for state instance data you allocated during state entry. It's designed like a destructor and so doesn't provide any parameters other than itself.</p>
<dl class="params"><dt>Parameters:</dt><dd>
  <table class="params">
    <tr><td class="paramname">hsm_context_t*</td><td>The context being freed</td></tr>
  </table>
  </dd>
</dl>
<dl class="section see"><dt>See also:</dt><dd><a class="el" href="hsm__context_8h.html#ab3a13b1fa2faea3f79edb11b10217a1a" title="Resets the hsm_context_stack structure.">HsmContextStack</a>, <a class="el" href="hsm__state_8h.html#a0cb7e4f750bdd83a03d75df4714f2efa" title="Macro for declaring a state + enter callback.">HSM_STATE_ENTER</a> </dd></dl>

<p>Definition at line <a class="el" href="hsm__context_8h_source.html#l00032">32</a> of file <a class="el" href="hsm__context_8h_source.html">hsm_context.h</a>.</p>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="a37882939881b43db4f51a7cc24544f11"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="hsm__forwards_8h.html#aa0e37ff043d2dd5216cc762ca03046cb">hsm_context</a> HsmContextAlloc </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>size</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Helper to create a new context object. </p>
<p>It will be auto-freed when popped.</p>
<dl class="params"><dt>Parameters:</dt><dd>
  <table class="params">
    <tr><td class="paramname">size</td><td>Total size of the user context structure. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns:</dt><dd>Newly allocated context data, NULL if the allocation failed.</dd></dl>
<p>Sets the <a class="el" href="hsm__context_8h.html#ad0208ce8f889006d0c5f3d92c030dd2b" title="per context callback">hsm_context_rec::popped</a> handler to an internal free function. You can also allocate your objects on your own if you want more control. </p>

<p>Definition at line <a class="el" href="hsm__context_8c_source.html#l00026">26</a> of file <a class="el" href="hsm__context_8c_source.html">hsm_context.c</a>.</p>

</div>
</div>
<a class="anchor" id="ab3a13b1fa2faea3f79edb11b10217a1a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="hsm__context_8h.html#structhsm__context__stack__rec">hsm_context_stack</a> HsmContextStack </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="hsm__context_8h.html#structhsm__context__stack__rec">hsm_context_stack_t</a> *&#160;</td>
          <td class="paramname"><em>stack</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="hsm__forwards_8h.html#aa0e37ff043d2dd5216cc762ca03046cb">hsm_context</a>&#160;</td>
          <td class="paramname"><em>init</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Resets the hsm_context_stack structure. </p>
<dl class="params"><dt>Parameters:</dt><dd>
  <table class="params">
    <tr><td class="paramname">stack</td><td>Stack to initialize. </td></tr>
    <tr><td class="paramname">init</td><td>Optional starting state; pushes record differences from this. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns:</dt><dd>The stack passed in. </dd></dl>
<dl class="section see"><dt>See also:</dt><dd><a class="el" href="hsm__stack_8h.html#a4ea4539c5534390f7885ae78bcf40019" title="Add a new context to the stack.">HsmContextPush</a> </dd></dl>

<p>Definition at line <a class="el" href="hsm__context_8c_source.html#l00039">39</a> of file <a class="el" href="hsm__context_8c_source.html">hsm_context.c</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_6c36b64852547327283732128225c9d7.html">hsm</a></li><li class="navelem"><a class="el" href="hsm__context_8h.html">hsm_context.h</a></li>
    <li class="footer">Generated on Sat Jul 7 2012 22:48:11 for hsm-statechart by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.1.1 </li>
  </ul>
</div>
</body>
</html>
